package com.yc.navy.dayfresh.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.navy.dayfresh.bean.CartInfo;
import com.yc.navy.dayfresh.dto.CartInfoDTO;
import com.yc.navy.dayfresh.mapper.ICartInfoMapper;
import com.yc.navy.dayfresh.service.ICartInfoService;
import com.yc.navy.dayfresh.util.StringUtil;

@Service
public class CartInfoServiceImpl implements ICartInfoService {
	@Autowired
	private ICartInfoMapper cartInfoMapper;

	@Override
	public int add(CartInfo cf) {
		if(StringUtil.checkNull(cf.getCno(),cf.getPno(),cf.getNum())) {
			return -1;
		}
		return cartInfoMapper.add(cf);
	}

	@Override
	public List<CartInfoDTO> findByMno(Long mno) {
		return cartInfoMapper.findByMno(mno);
	}

	@Override
	public int delete(String[] cnos) {
		return cartInfoMapper.delete(cnos);
	}

	@Override
	public int update(CartInfo cf) {
		if(StringUtil.checkNull(cf.getNum(),cf.getCno())) {
			return -1;
		}
		return cartInfoMapper.update(cf);
	}

	@Override
	public List<CartInfoDTO> findByPnos(List<String> pnos) {
		return cartInfoMapper.findByPnos(pnos);
	}
}
